﻿using System;
using System.Windows.Controls;
using WiMo.Games.Drawables;
using WiMo.Games.Drawing.Silverlight;

namespace WiMo.Games.Drawing.Silverlight.Drawables
{
    public class Ellipse : SpriteShapeBase
    {
        System.Windows.Shapes.Ellipse _ellipse;

        public Ellipse()
        {
            ShapeType = WiMo.Games.Drawables.ShapeType.Ellipse;
        }

        public override void Render(IDisplay display)
        {
            _ellipse = new System.Windows.Shapes.Ellipse();

            if (this.BorderColor != Color.Transparent)
            {
                _ellipse.Stroke = new System.Windows.Media.SolidColorBrush(this.BorderColor.GetMediaColor());
                _ellipse.StrokeThickness = this.BorderWidth;
            }

            if (this.FillColor != Color.Transparent)
                _ellipse.Fill = new System.Windows.Media.SolidColorBrush(FillColor.GetMediaColor());                        

            _ellipse.Width = Size.Width;
            _ellipse.Height = Size.Height;

            if (Origin == WiMo.Games.Drawables.Origin.Center)
            {
                _ellipse.SetValue(Canvas.TopProperty, (double)(Position.Y - (Size.Height / 2)));
                _ellipse.SetValue(Canvas.LeftProperty, (double)(Position.X - (Size.Width / 2)));
            }
            else
            {
                _ellipse.SetValue(Canvas.TopProperty, (double)(Position.Y));
                _ellipse.SetValue(Canvas.LeftProperty, (double)(Position.X));
            }

            DrawInformation = _ellipse;

            display.Render(this);
        }

    }
}
